package com.dd.ent.car.ui.home.templet.graphic;


import android.view.View;
import android.widget.AdapterView;

import com.dd.ent.car.common.bean.base.PageBean;
import com.dd.ent.car.common.bean.base.ResultBean;
import com.dd.ent.car.common.bean.graphic.Graphic;
import com.dd.ent.car.common.share.ShareHelper;
import com.dd.ent.car.common.share.ShareInfo;
import com.dd.ent.car.common.share.ShareListener;
import com.dd.ent.car.service.home.piece.GraphicService;
import com.dd.ent.car.ui.adapter.base.BaseListAdapter;
import com.dd.ent.car.ui.adapter.general.GraphicAdapter;
import com.dd.ent.car.ui.home.templet.HomeTempletListFragment;
import com.google.gson.reflect.TypeToken;
import com.pp.ent.view.annotation.Inject;

import java.lang.reflect.Type;
import java.util.HashMap;

import cn.sharesdk.framework.Platform;

/**
 * 图文fragment
 * Created by aqu-spring on 16/8/7.
 */
public class GraphicFragment extends HomeTempletListFragment<Graphic> {
    private final static String TAG = "GraphicFragment";
    @Inject
    private GraphicService pieceService;


    @Override
    protected BaseListAdapter<Graphic> getListAdapter() {
        return new GraphicAdapter(this);
    }

    @Override
    protected void initData() {
        super.initData();
        requestData();
    }

    @Override
    protected void requestData() {
        super.requestData();
        //pieceService.getListPiece();
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        ShareHelper.share(ShareHelper.SharePlatform.QQZONE, new ShareListener() {
            @Override
            public void onComplete(Platform var1, int var2, HashMap<String, Object> var3) {

            }

            @Override
            public void onError(Platform var1, int var2, Throwable var3) {

            }

            @Override
            public void onCancel(Platform var1, int var2) {

            }

            @Override
            public ShareInfo getShareInfo() {
                ShareInfo shareInfo = new ShareInfo();
                shareInfo.title = "测试分享的标题";
                shareInfo.titleUrl="http://sharesdk.cn";
                shareInfo.text = "测试分享的文本";
                shareInfo.imageUrl="http://www.someserver.com/测试图片网络地址.jpg";
                shareInfo.site="发布分享的网站名称";
                shareInfo.siteUrl="发布分享网站的地址";
                return shareInfo;
            }
        });
    }

    @Override
    protected Type getType() {
        return new TypeToken<ResultBean<PageBean<Graphic>>>() {
        }.getType();
    }

//    @UIHandler(UIConfig.GETLISTPIECERES)
//    public void getListPieceRes(JSONObject jsonObject) {
//        MLog.d(TAG, "getListPieceRes jsonObject=" + jsonObject);
//        ResultBean<PageBean<Graphic>> resultBean = AppContext.createGson().fromJson(jsonObject.toString(), getType());
//        setListData(resultBean);
//        onRequestFinish();
//    }


}
